package com.crime.crimemonitorclient;

import java.io.InputStream;
import java.util.Calendar;

import android.util.Log;

public final class Utils
{
	public static String readStreamIntoString(InputStream is)
	{
		java.util.Scanner s = null;
		try
		{
			s = new java.util.Scanner(is, "utf-8").useDelimiter("\\A");
			return s.hasNext() ? s.next() : "";
		}
		finally
		{
			try
			{
				if (s != null)
					s.close();
			}
			catch (Exception e)
			{
				Log.e("Read", "Error closing the Scanner of a pie chart page.",
						e);
			}
		}
	}
	
	public static long getTimeInMillis(int year, int month)
	{
		Calendar calendar = Calendar.getInstance();
		
		calendar.clear();
		calendar.set(Calendar.YEAR, year);
		calendar.set(Calendar.MONTH, month);
		
		return calendar.getTimeInMillis();
	}
}
